package VueDemo.Controller;

import VueDemo.Mapper.UserMapper;
import VueDemo.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Ychiha
 * @version 1.0
 * @date 23/12/2021 下午8:09
 */
//@Controller
@RestController
@CrossOrigin    //处理跨域 SpringMVC
public class UserController {

    @Autowired
    UserMapper userMapper;


    @RequestMapping("/getuserlist")
    public List<User> getUserList(){
        System.out.println("okokokok");
        List<User> list = (List<User>)userMapper.getUserList();
        for(User u : list){
            System.out.println(u);
        }
        return list;
    }

    @RequestMapping("/senddata")
    public void sendData(@RequestBody User user){
        System.out.println(user);
    }

}
